package com.zy.smbms.service;

import com.zy.smbms.UserMapper.SmbmsUserMapper;
import com.zy.smbms.pojo.SmbmsUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SmbmsUserServiceImpl implements SmbmsUserService
{
    @Autowired
    private SmbmsUserMapper smbmsUserMapper;
    @Override
    //根据用户名和密码查询，登录验证
    public SmbmsUser selectUserByUsername(SmbmsUser user)
    {
        return smbmsUserMapper.selectUserByUsername(user);
    }

    //模糊查询，根据用户名查询所有数据,分页查询
    @Override
    public List<SmbmsUser> selectUserList(Map<String,Object> map)
    {
        return smbmsUserMapper.selectUserListByUsername(map);
    }

    //查询数据总条数
    @Override
    public int selectTotalByUsername(SmbmsUser user)
    {
        return smbmsUserMapper.selectTotalByUsername(user);
    }

    //增加用户信息
    @Override
    public int addUser(SmbmsUser user)
    {
        return smbmsUserMapper.addUser(user);
    }

    //根据主键查询信息
    @Override
    public SmbmsUser selectUserById(Long id)
    {
        return smbmsUserMapper.selectByPrimaryKey(id);
    }

    //更新用户信息
    @Override
    public int updateUserById(SmbmsUser user)
    {
        return smbmsUserMapper.updateByPrimaryKeySelective(user);
    }

    //删除用户信息
    @Override
    public int deleteUserById(Long id)
    {
        return smbmsUserMapper.deleteByPrimaryKey(id);
    }
}
